//
//  BaseSceneModel.m
//  BrushFace
//
//  Created by Zzz on 15/12/20.
//  Copyright © 2015年 Zzz. All rights reserved.
//

#import "BaseSceneModel.h"

@implementation BaseSceneModel
-(void)sendRequest:(Request *)req
           success:(void (^)())successHandler
             error:(void (^)())errorHandler{
    //    [self.action useCache];
    
    
    [RACObserve(req, state) //监控 网络请求的状态
     subscribeNext:^(NSNumber *state) {
         if(req.succeed && successHandler){
             successHandler();
         }else if (req.failed && errorHandler){
             errorHandler();
         }
     }];
    [self SEND_ACTION:req];
}

- (NSString *)replayRequestStr:(NSString *)baseStr{
    NSMutableString *reasonMutable = [[NSMutableString alloc] init];
    for (int i=0; i<baseStr.length; i++) {
        UniChar b = [baseStr characterAtIndex:i];
        NSString *str = [ [NSString alloc] initWithFormat:@"%x",b];
        while (str.length<4) {
            str = [NSString stringWithFormat:@"0%@",str];
        }
        [reasonMutable appendString:str];
    }
    return reasonMutable;
}
@end
